package com.ruoyi.web.controller.books;

import com.jhlabs.image.ShineFilter;
import com.ruoyi.books.domain.BookManage;
import com.ruoyi.books.domain.BookRecord;
import com.ruoyi.books.service.IBookManageService;
import com.ruoyi.books.service.IBookRecordService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysDictData;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.utils.uuid.UUIDUtils;
import com.ruoyi.framework.web.domain.server.Sys;
import com.ruoyi.system.service.ISysDictDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.security.Permission;
import java.util.Date;
import java.util.List;

/**
 * 图书信息Controller
 *
 * @author wt
 * @date 2025-03-15
 */
@RestController
@RequestMapping("/books/borrow")
public class BookBorrowController extends BaseController
{
    @Autowired
    private IBookManageService bookManageService;
    @Autowired
    private ISysDictDataService iSysDictDataService;
    @Autowired
    private IBookRecordService iBookRecordService;

    /**
     *  查询图书信息列表
     */
    @PreAuthorize("@ss.hasPermi('books:borrow:query')")
    @GetMapping("/selectBookInfo/{id}")
    public AjaxResult selectBookInfo(@PathVariable String id)
    {
        //图书信息
        BookManage bookInfo = bookManageService.selectBookManageById(id);
        //组装领取信息
        BookRecord record = new BookRecord();
        record.setId(UUIDUtils.uuid());
        record.setBookId(id);
        record.setBookName(bookInfo.getBookName());
        record.setBookState("0");
        LoginUser loginUser = SecurityUtils.getLoginUser();
        record.setUserId(loginUser.getUser().getUserId());
        record.setNickName(loginUser.getUser().getNickName());
        record.setOutTime(new Date());
        return success(record);
    }

    
}
